export default class ZDog {
  constructor() {
    this.list = [] //任务队列
    this.state = 0 //0空闲 1忙碌
  }
  doSome(some) {
    this.list.push(some)
  }
  run() {
    if (this.state == 0) {
      this.state = 1
      let fn = this.list.shift()
      if (fn) {
        fn(() => {
          this.state = 0
          this.run()
        })
      } else {
        this.state = 0
      }
    }
  }
  start() {
    this.run()
  }
}

export class V2Dog extends ZDog {
  constructor() {
    super()
  }
  doFirst(some) {
    this.list.unshift(some)
  }
}
